<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //指构造函数的prototype属性是否在某个实例的原型链上
function instanceofObj(a, b) {
    // 模拟 a instanceof b
    let prototypeB = b.prototype;
    let protoA = a.__proto__;
    let state = false;
    while (true) {
        if (protoA == null) { // 可能是 undefined 
            state = false;
            break;
        }
        if (prototypeB === protoA) {
            state = true;
            break;
        }
        protoA = protoA.__proto__;
    }
    return state;
}
console.log(instanceofObj([], Array));
instanceofObj([], Array); //true
  </script>
</body>
</html>